﻿using Face8280WebSocketServer.DTO.FaceRecard;
using Face8280WebSocketServer.Interface;
using Face8280WebSocketServer.Utility.FilterAttribute;
using Face8280WebSocketServer.Utility.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace FaceFace8280WebSocketServer.Controllers.New.Record
{
    [Route("api/[controller]")]
    [ApiController]
    public class FaceRecordController : ControllerBase
    {
        IFaceRecordService _FaceRecordService;
        public FaceRecordController(IFaceRecordService recordService)
        {
            _FaceRecordService = recordService;
        }
        /// <summary>
        /// 获取设备列表数据
        /// </summary>
        /// <param name="par"></param>
        /// <returns></returns>
        [HttpPost]
        [Route("GetCardRecordPage")]
        [Authorize]
        [TypeFilter(typeof(VerifyActionFilterAttribute))]
        public IActionResult GetCardRecordPage([FromForm] QueryCardRecordParameter parameter)
        {
            if (parameter.StartTime == DateTime.MinValue)
            {
                parameter.StartTime = DateTime.Now.Date;
            }
            if (parameter.EndTime == DateTime.MinValue)
            {
                parameter.EndTime = DateTime.Now.AddDays(1).Date;
            }
            return new JsonResult(_FaceRecordService.GetCardRecordList(parameter));
        }
        [HttpPost]
        [Route("ClearReport")]
        [Authorize]
        [TypeFilter(typeof(VerifyActionFilterAttribute))]
        public IActionResult ClearReport()
        {
            _FaceRecordService.ClearReport();
            return new JsonResult(new JsonResultModel());
        }
    }
}
